// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.rcp.intro;

import org.dengues.commons.IDenguesCoreContants;
import org.dengues.core.warehouse.IWarehouseView;
import org.dengues.designer.ui.wizards.DBEditorNewWizard;
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * $Id: Dengues.epf Qiang.Zhang.Adolf@gmail.com 2008-1-17 qiang.zhang $
 * 
 */
public class DenguesETLPerspective implements IPerspectiveFactory {

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
     */
    public void createInitialLayout(IPageLayout layout) {
        // layout.setEditorAreaVisible(false);
        defineActions(layout);
        defineViewers(layout);
    }

    /**
     * Qiang.Zhang.Adolf@gmail.com Comment method "defineViewers".
     * 
     * @param layout
     */
    private void defineViewers(IPageLayout layout) {
        IFolderLayout leftTopfolder = layout.createFolder("navigatorLayout", IPageLayout.LEFT, 0.3f, //$NON-NLS-1$
                IPageLayout.ID_EDITOR_AREA);
        leftTopfolder.addView(IWarehouseView.VIEW_ID);
        // Add a placeholder for the old navigator to maintain compatibility
        // leftTopfolder.addPlaceholder("org.eclipse.ui.views.ResourceNavigator");
        leftTopfolder.addView(IPageLayout.ID_RES_NAV);

        IFolderLayout leftBottomLayout = layout.createFolder("outlineCodeLayout", IPageLayout.BOTTOM, new Float(0.6), //$NON-NLS-1$
                IWarehouseView.VIEW_ID);
        // leftBottomLayout.addView(IPageLayout.ID_OUTLINE);
        leftBottomLayout.addView(IDenguesCoreContants.CODE_VIEW_ID);
        leftBottomLayout.addView(IDenguesCoreContants.QUERY_VIEW_ID);

        String pdeErrorViewId = "org.eclipse.pde.runtime.LogView"; //$NON-NLS-1$
        // layout.addStandaloneView(NavigationView.ID, true, IPageLayout.RIGHT,
        // 0.2f, editorArea);
        // layout.getViewLayout(NavigationView.ID);
        IFolderLayout bottomLayout = layout.createFolder("bottomLayout", IPageLayout.BOTTOM, new Float(0.635), //$NON-NLS-1$
                IPageLayout.ID_EDITOR_AREA);
        bottomLayout.addView(pdeErrorViewId);
        bottomLayout.addView(IDenguesCoreContants.VIEW_COMPONENT_PROPERTY_ID);
        bottomLayout.addView(IPageLayout.ID_PROBLEM_VIEW);
    }

    private void defineActions(IPageLayout layout) {
        // Add "new wizards".
        layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder"); //$NON-NLS-1$
        layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file"); //$NON-NLS-1$
        layout.addNewWizardShortcut(DBEditorNewWizard.ID);

        // Add "show views".
        layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
        layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
        layout.addShowViewShortcut(IDenguesCoreContants.VIEW_COMPONENT_PROPERTY_ID);

    }
}
